{% extends "profiles/base_profile_edit.html" %}

{% load i18n %}

{% block title %}{% trans "Connected Services" %}{% endblock %}

{% block edit_content_header %} {% trans "Connected Services" %} {% endblock %}

{% block profile-admin-social-accounts %}active{% endblock %}

{% block edit_content %}

  <div class="module connected-services">
    <div class="module-wrapper">
      <p>
        {% blocktrans trimmed %}
          The following services are currently connected to your account:
        {% endblocktrans %}
      </p>

      {# TODO: style this properly in the new templates #}
      {% if form.non_field_errors %}
      {{ form.non_field_errors }}
      {% endif %}

      <div class="module-list-wrapper">
        {% if form.accounts %}
          <ul>

            {% for base_account in form.accounts %}
              {% with base_account.get_provider_account as account %}
                <li class="module-item">

                  <img src="{{ base_account.get_avatar_url }}" class="account-gravatar" height=24 width=24 />

                  <span>
                    {{ account }}
                    <span class="socialaccount_provider {{ base_account.provider }} {{ account.get_brand.id }}">
                      ({{ account.get_brand.name }})
                    </span>
                  </span>

                  <ul class="module-item-menu">
                    <li>
                      <form method="post" action="{% url 'socialaccount_connections' %}">
                        {% csrf_token %}
                        <input type="hidden" name="account" value="{{ base_account.id }}" />
                        <input type="submit" name="submit" value="{% trans 'Disconnect' %}" />
                      </form>
                    </li>
                  </ul>

                  {% if base_account.provider == 'bitbucket' %}
                    <p class="help error">
                      {% blocktrans trimmed %}
                        The API version this connection uses is no longer
                        supported, please reconnect your Bitbucket account.
                      {% endblocktrans %}
                    </p>
                  {% endif %}

                </li>
              {% endwith %}
            {% endfor %}

          </ul>

        {% else %}
          <ul>
            <li class="module-item">
              <p>{% trans 'You currently have no social network accounts connected to this account.' %}</p>
            </li>
          </ul>
        {% endif %}

      </div>
    </div>
  </div>

  <ul class="socialaccount_providers">
    {% include "socialaccount/snippets/provider_list.html" with process="connect" next="" %}
  </ul>

  {% include "socialaccount/snippets/login_extra.html" %}

{% endblock %}
